package com.woniuxy.main.util;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.UUID;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

//小工具类
public class MyUtil {
	
	//获取当前日期
	public static String getDate(){
		Calendar calendar= Calendar.getInstance();
		SimpleDateFormat dateFormat= new SimpleDateFormat("yyyy-MM-dd");
		return dateFormat.format(calendar.getTime());
	}
	
	//随机生成用户名
	public static String randomAccount(){
		String account="WoniuYoga-"+UUID.randomUUID().toString().substring(0, 6);
		return account;
	}
	
	//验证邮箱
	public static boolean isEmail(String email){  
		if (null==email || "".equals(email)){
        	return false; 
        }
        String regEx1 = "^([a-z0-9A-Z]+[-|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$"; 
        Pattern p = Pattern.compile(regEx1);
        Matcher m = p.matcher(email);
        if(m.matches()){
        	return true;
        }else{
        	return false;
        }
	}

}
